#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>

using namespace std;

class Solution {
public:
    string reverseStr(string s, int k) {
        int n = s.size();
        for (int i = 0; i < n; i += (2 * k))
        {
            if (i + k <= n)
            {
                reverse(s.begin() + i, s.begin() + i + k);
            }
            else
            {
                 reverse(s.begin() + i, s.end());
            }
        }
    return s;
    }
};